<?php

class Ext_Blog_Validate
{
    protected $_validaters = array();
    protected $_messages = array();

    public function __construct()
    {
    }
    
    public function addValidater(Ext_Blog_Validate_Interface $validater)
    {
        $this->_validaters[] = $validater;
        
        return $this;
    }
    
    public function isValid()
    {
        $result = true;
        foreach ($this->_validaters as $validater) {
            if ($validater->isValid()) {
                continue;
            }
            $result = false;
            $messages = $validater->getMessages();
            $this->addMessages($messages);
        }
        return $result;
    }
    
    public function addMessage($message)
    {
        $this->_messages[] = $message;
    }
    
    public function addMessages($messages)
    {
        $this->_messages = array_merge($this->_messages, $messages);
    }
    
    public function getMessages()
    {
        return $this->_messages;
    }
}
